﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OnlineBookstore
{
    public class cl_0423_SilverLevel : cl_0423_AbstractLevel
    {
        public cl_0423_SilverLevel(cl_0423_AbstractLevel level)
        {
            this.acc = level.acc;
            this.point = level.getPoint();
            this.LevelName = "银卡会员";
        }

        public override void BuyBook(int paidMoney)
        {
            this.point += paidMoney;
            acc.paidMoney += paidMoney;
            Console.WriteLine(acc.getName() + "购买书籍" + paidMoney + "元");
            Console.WriteLine("增加积分：" + paidMoney);
            checkLevel();
            Console.WriteLine("剩余积分:" + this.point + ",当前级别:" + acc.getLevel().getLevelName());
        }

        public override void CalcRealAmount()
        {
            Console.WriteLine("银卡会员打九折,理论消费总计为:" + acc.paidMoney);
            Console.WriteLine("最终支付为：" + (Double)acc.paidMoney * 0.9 + "元"); ;
        }

        public override void ChangeCredit()
        {
            point -= 30;
            Console.WriteLine(acc.getName() + "兑换礼品2，扣除30积分，剩余积分:" + this.point);
            checkLevel();
            Console.WriteLine("当前级别:" + acc.getLevel().getLevelName());
        }

        public void checkLevel()
        {
            if (point > 500)
            {
                acc.setLevel(new cl_0423_DiamondLevel(this));
            }
            else if (point > 300)
            {
                acc.setLevel(new cl_0423_GoldLevel(this));
            }
            else if (point <= 100)
            {
                acc.setLevel(new cl_0423_OrdinaryLevel(this));
            }
        }
    }
}